﻿function direct(year) {
    var _url = location.href;

    _url = redirectPage('year', year, _url);

   window.location.href = _url;
}
function redirectPage(key, value, oldurl) {
    var Request = new Array();
    loadQueryString(Request, oldurl);
    var qx = Request["year"];
    var time = Request["VillageName"];
    var line = Request["departmentid"];
  
    var url = oldurl;
    var index = url.indexOf('?');
    if (index != -1)
        url = url.substring(0, index);

    var qxparam = '';
    var timeparam = '';
    var endtimeparam = '';
    var lineparam = '';
    var params = '';
    if (key == "year") {
        qxparam = '&year=' + value;
    }
    else {
        if (qx != undefined)
            qxparam = '&year=' + qx;
    }
    if (key == "VillageName") {
        timeparam = '&VillageName=' + value;
    }
    else {
        if (time != undefined)
            timeparam = '&VillageName=' + time;

    }

    if (key == "departmentid") {
        lineparam = '&departmentid=' + value;

    }
    else {
        if (line != undefined)
            lineparam = '&departmentid=' + line;

    }
    params = qxparam + timeparam  + lineparam;
    if (params.length > 0) {
        params = params.substring(1, params.length);
    }
   
    if (params != '')
        url = url + '?' + params;
    return url;
}
function loadQueryString(Request, url) {
    var str = '';
    var s = url;

    var n = s.indexOf("?");
    if (n >= 0)
        s = s.substring(n + 1);

    var valuelist = s.split("&");
    for (var i = 0; i < valuelist.length; i++) {
        var pair = valuelist[i].split("=");
        if (pair.length > 1) {
            Request[pair[0]] = pair[1];

        }
    }
}        